﻿using NiYo.ParserBuilder.Domain.Hl7.Enums;

namespace NiYo.ParserBuilder.Domain.Hl7.DataTypes
{
    /// <summary>
    /// Type of MSH-9
    /// </summary>
    public class CompositeMessageType : Hl7DataType
    {
        /// <summary>
        /// The message type code (ACK, ADT, ORM, ORU, ...)
        /// Standard HL7 position: 1
        /// </summary>
        public MessageType MessageTypeCode { get; set; }

        /// <summary>
        /// The trigger event code (A01, O01, R01, ...)
        /// Standard HL7 position: 2
        /// </summary>
        public TriggerEvent? TriggerEventCode { get; set; }

        /// <summary>
        /// Abstract message structure definition
        /// Standard HL7 position: 3
        /// </summary>
        public string MessageStructureId { get; set; }

        #region "- Helper Methods -"

        /// <summary>
        /// To compare current CompositeMessageType with another CompositeMessageType
        /// </summary>
        private bool Equals(CompositeMessageType other)
        {
            return !ReferenceEquals(null, other);
        }

        /// <summary>
        /// To compare current CompositeMessageType with another object
        /// </summary>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof(CompositeMessageType)) return false;
            return Equals((CompositeMessageType)obj);
        }

        /// <summary>
        /// Used by equals
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return 0;
        }

        #endregion
    }
}
